package com.web.portal.dao;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.web.portal.entity.Admin;
import com.web.portal.entity.AdvisorMeeting;

@Repository(value = "adminDao")
public class AdminDaoImpl extends WebportalBaseDao<Admin> implements AdminDao {
private static final Logger LOG=Logger.getLogger(AdminDaoImpl.class);
	public Admin getByUserNameAndPassword(String userName, String password) {
		// TODO Auto-generated method stub
		return null;
	}

	protected void populateCriteria(
			Map<? extends Enum<?>, Object> searchCriteria, Criteria criteria) {
		if (searchCriteria.containsKey(WebportalSearchType.USER_NAME)) {
			criteria.add(Restrictions.eq("userName",
					searchCriteria.get(WebportalSearchType.USER_NAME)));
		}
		if (searchCriteria.containsKey(WebportalSearchType.PASSWORD)) {
			criteria.add(Restrictions.eq("password",
					searchCriteria.get(WebportalSearchType.PASSWORD)));
		}

	}

	public List<Admin> listItems(Admin instance) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
				LOG.debug("Geeting list of Advisor meeting from database");
				try{
					@SuppressWarnings("unchecked")
					List<Admin> result =getSession().createQuery("from Admin").list();
					if(result.isEmpty()){
						LOG.debug("List is empty for Advisor meeting.............................");
					}
					return result;
				}catch(HibernateException e){
					
					LOG.debug("unable to find the item Advisor meeting......................");
					throw e;
				}
	}

}
